package com.example.myapplication;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class zhexian extends AppCompatActivity {
    private EditText input;
    private TextView bz;
    private TextView result;
    float hv;



    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_zhexian);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
        input =findViewById(R.id.v1);
        bz =findViewById(R.id.v2);
        result=findViewById(R.id.v1);


        Intent intent=getIntent();
        String bz1 = String.valueOf(intent.getFloatExtra("title",0.1f));
        float hv1 = intent.getFloatExtra("detail",0.1f);

        bz.setText(String.valueOf(bz1));
        hv=hv1;

    }
    public void click(View bt){
        String strrmb = input.getText().toString();
        try {
            float rmb = Float.parseFloat(strrmb);
            float re = 0;
            if (bt.getId() == R.id.bt1) {
                re = rmb*hv;
            }
            result.setText(String.valueOf(re));
        }catch (NumberFormatException e){
            Toast.makeText(this,"请输入正确的数据",Toast.LENGTH_SHORT).show();
        }
    }
}